<template>
  <div>
    <van-nav-bar title="我的" right-text="退出" @click-right="onClickRight" />
    <p>你好，{{ username }}</p>
    <bottom :active="3"></bottom>
  </div>
</template>

<script>
import Bottom from "@/components/Bottom.vue";
import { Dialog } from 'vant';
export default {
  components: { Bottom 
  ,[Dialog.Component.name]: Dialog.Component,
  },
  data() {
    return {
      username: "",
    };
  },
  created() {
    const username = window.sessionStorage.getItem("username");
    this.username = username;
  },
  methods: {
    onClickRight() {
      Dialog.confirm({
        title: "确认",
        message: "您确认退出吗?",
      })
        .then(() => {
          // on confirm
          window.sessionStorage.removeItem('username')
          this.$toast.success('退出成功')
          this.$router.replace('/')
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style>
</style>